//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package SaveServlet.course;

import com.lyq.bean.Course;
import com.lyq.bean.service.C_Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet({"/UpdateCourse_Servlet"})
public class UpdateCourse_Servlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public UpdateCourse_Servlet() {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String No = request.getParameter("No");
        List<Course> list = new ArrayList();
        list = (new C_Service()).seek_C("编号", "精确查询", No, list);
        request.getSession().setAttribute("list", list);
        request.getSession().setAttribute("c", list.toArray()[0]);
        request.getRequestDispatcher("/jsp/course/m/UpdateCourse.jsp").forward(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String No = ((Course)request.getSession().getAttribute("c")).getNo();
        String time = request.getParameter("time");
        String place = request.getParameter("place");
        String credit = request.getParameter("credit");
        Boolean bool = (new C_Service()).update_C(No, time, place, credit);
        if (bool) {
            request.getSession().setAttribute("message", "修改课程成功！");
        } else {
            request.getSession().setAttribute("message", "修改课程失败！");
        }

        request.getSession().setAttribute("url", "RemoveCourse_Servlet?id=seekall");
        request.getRequestDispatcher("Message.jsp").forward(request, response);
    }
}
